#ifndef __SOFTWARE_TIMER_H__
#define __SOFTWARE_TIMER_H__

#include "stm32f10x.h"
#include "typedefs.h"

#define HOME_BLINK_SOFTTIMERx			0
#define BUZZER_SOFTTIMERx				1
#define MOTOR_RUN_SORTTIMERx			2
#define REGION_BLINK_SOFTTIMERx			3
#define PICK_TIMING_SOFTTIMERx			4
#define COM_TIMING_SOFTTIMERx			5
#define FREE_SOFTTIMERx					6

#define SOFTWARE_TIMER_NUM				(FREE_SOFTTIMERx + 1)

typedef void (*timeout_handler)();

typedef struct
{
	uint8_t id;
	uint32_t count;
	uint32_t expire;
	timeout_handler callback;
	uint8_t isEnable;	//0,disable 1,enable
	int16_t repeat;		//-1,forever
} SoftwareTimerStruct;

void SoftwareTimer_Tick(void);
void SoftwareTimer_Init(uint8_t id,uint32_t expire,timeout_handler callback,int16_t repeat);
void SoftwareTimer_Enable(uint8_t id);
void SoftwareTimer_Disable(uint8_t id);
uint8_t SoftwareTimer_IsEnable(uint8_t id);
void SoftwareTimer_ResetCount(uint8_t id);
uint32_t SoftwareTimer_ReadCount(uint8_t id);
void SoftwareTimer_SetExpire(uint8_t id,uint32_t expire);
void SoftwareTimer_SetRepeat(uint8_t id,int16_t repeat);


#endif

